<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/website/layout/tag.jsp"%>
<script type="text/javascript">
	$(document).ready(
		function() {
			//事件注册.
			$("#searchBtn").click(searchOrder);
			$("#modifyBtn").click(modifyOrder);
			$("#sendBtn").click(
				function() {
					changeOrderStatus("2");
				});
				
			$("#recBtn").click(
				function() {
					changeOrderStatus("3");
				});
			$("#delBtn").click(function() {
					changeOrderStatus("4");
				});
				
			//checkbox控件事件注册.
			$("[name='chkAll']").each(
				function() {
					$(this).click(function() {
						checkAll("chkAll", "chkEach");
					});
				}
			);
			$("[name='chkEach']").each(
				function() {
					$(this).click(function() {
						checkEach("chkAll", "chkEach");
					});
				}
			);
			
			//设置左菜单对应菜单CSS为选中状态.
			changeToActiveCss("menu_3010");
			
			//消息显示.
			var msg = '<c:out value="${msg}"/>';
			if (msg != "") {
				alert(msg);
			}
		}
	);
	
	function modifyOrder() {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要编辑的订单.");
			return false;
		}
		
		if (len > 1) {
			alert("请只选择一条订单.");
			return false;
		}
		
		window.location.href='${pageContext.request.contextPath}/order/enterOrderModify.do?oper=modify&sysId=' + checkObjs[0].value;
	}
	
	function searchOrder() {
		$("#searchForm").submit();
	}
	
	function changeOrderStatus(newStatus) {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要编辑的订单.");
			return false;
		}
		
		if (len > 1) {
			alert("请只选择一条订单.");
			return false;
		}
		
		var orderId = checkObjs[0].value;
		if(confirm("确定要改变订单状态吗?")) {
			var action = "${pageContext.request.contextPath}/order/changeOrderStatus.do";
			action += "?orderId=" + orderId + "&newStatus=" + newStatus;
			$("#searchForm").attr("action", action);
			$("#searchForm").submit();
		}
	}
	
	function showStopDlg() {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要屏蔽的会员.");
			return false;
		}
		
		if (len > 1) {
			alert("请只选择一条会员.");
			return false;
		}
		
		$("#sysId").val(checkObjs[0].value);
		$("#stopDlg").show().css("top",($(document).height()-140)/2 ).css("left",($(document).width()-400)/2 );
	}
	
	function cancelStop() {
		$("#stopLog").val("");
		$("#stopDlg").hide()
	}
	
	function stopMember() {
		$("#stopLog").val($("#stopLogInput").val());
		$("#searchForm").attr("action", "${pageContext.request.contextPath}/member/stopMember.do");
		$("#searchForm").submit();
	}
</script>
<div id="content_right">
	<div style="width:100%;height:35px;line-height:35px;text-align:left;background-color:#F5FAFA;font-weight:bold; ">订单 > 租书订单管理 > 全部订单</div>
	<div id="searchArea">
		<table width="100%" cellspacing="0">
			<tr>
				<td width="60px" align="right">订单状态:</td>
				<td width="80px" align="left">
				</td>
				<td width="60px" align="right">订单编号:</td>
				<td width="100px" align="left"></td>
				<td width="60px" align="right">用户ID:</td>
				<td width="110px" align="left"></td>
				<td width="60px" align="right">会员名:</td>
				<td width="80px" align="left"></td>
				<td width="60px" align="right">收货人:</td>
				<td width="80px" align="left"></td>
				<td></td>
			</tr>
			<tr>
				<td align="right">下单日期:</td>
				<td align="left" colspan="3">
					
				</td>
				<td align="right">送货日期:</td>
				<td align="left" colspan="3">
				</td>
				<td align="right">送货员:</td>
				<td align="left"></td>
				<td>
				</td>
			</tr>
			<tr>
				<td colspan="11">
					<div class="buttons" style="float:right; margin-right:40px;">
						<a id="searchBtn" href="#">
							<img src="../images/btn_search.gif" alt=""/> 
							检索
						</a>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<div id="btnArea">
		<div class="buttons">
			<a id="modifyBtn" href="#" title="[已完成]或[已作废]订单,不允许修改.">
				<img src="../images/btn_apply.png" alt=""/> 
				修改
			</a>
			
			<a id="sendBtn" href="#" style="margin-left:25px;" title="[待送书]状态的订单,允许修改为[已送书]状态.">
				<img src="../images/btn_apply.png" alt=""/> 
				送书
			</a>
			<a id="recBtn" href="#" class="regular" title="[已送书]状态订单,允许修改为[已完成]状态.">
				<img src="../images/btn_textfield_key.png" alt=""/> 
				还书
			</a>
			<a id="delBtn" href="#" class="regular" title="[待送书]或[已送书]状态订单,允许修改为[作废]状态. 订单作废以后,更新相关图书的在库数量,允许其他客户下单."><!-- class="regular"-->
				<img src="../images/btn_cross.png" alt=""/> 
				作废
			</a>
			
			<a id="exportBtn" href="#" style="margin-left:25px;">
				<img src="../images/btn_apply.png" alt=""/> 
				送货单导出
			</a>
		</div>
	</div>
	<div style="clear:both; "></div>
	<div id="resultArea" style="height:400px; ">
		<table class="dataTable" cellspacing="0"> 
			<tr> 
			<th scope="col" width="26px;"><input type="checkbox" name="chkAll"/></th> 
			<th scope="col" width="55px">订单</br>编号</th> 
			<th scope="col" width="15px">新</th> 
			<th scope="col" width="55px">订单</br>状态</th> 
			<th scope="col" width="70px">下单日期</th> 
			<th scope="col" width="90px">用户ID</th>
			<th scope="col" width="90px">会员名</th> 
			<th scope="col" width="60px">收货人</th> 
			<th scope="col" width="80px">收货人</br>电话</th> 
			<th scope="col" width="200px">收货人地址</th>
			<th scope="col" width="70px">送货日期</th> 
			<th scope="col" width="60px">送货员</th> 
			<th scope="col" >订单备注</th>
			</tr> 
			<tr> 
			<td class="row"> <input type="checkbox" name="chkEach" value="#"/></td>
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td>
			<td class="row">#</td>
			<td class="row">#</td>
			<td class="row">#</td> 
			<td class="row">#</td>
			<td class="row">#</td> 
			</tr> 
			
		</table> 
	</div>
</div>
